package com.resource.studentmanage.controller;

import java.util.Arrays;
import java.util.Map;

import com.resource.common.utils.PageUtils;
import com.resource.common.utils.R;
import com.resource.studentmanage.entity.TStudentWorkEntity;
import com.resource.studentmanage.feign.StudentDealRemote;
import com.resource.studentmanage.service.TStudentWorkService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 学生作业统计表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2023-04-06 15:51:24
 */
@RestController
@RequestMapping("student/tstudentwork")
@Slf4j
public class TStudentWorkController implements StudentDealRemote {
    @Autowired
    private TStudentWorkService tStudentWorkService;

    @Override
    @RequestMapping(value = "/submitfeedback",method = RequestMethod.POST)
    public void submitStudentWork(@RequestParam Map<String, String> map) {
        tStudentWorkService.submitStudentWork(map);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tStudentWorkService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		TStudentWorkEntity tStudentWork = tStudentWorkService.getById(id);

        return R.ok().put("tStudentWork", tStudentWork);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody TStudentWorkEntity tStudentWork){
		tStudentWorkService.save(tStudentWork);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody TStudentWorkEntity tStudentWork){
		tStudentWorkService.updateById(tStudentWork);

        return R.ok();
    }

    @RequestMapping(value = "/submitWork",method = RequestMethod.POST)
    public void dealStudentWork(@RequestParam Map<String, String> map) {
        log.info(map.toString());
        tStudentWorkService.dealStudentWork(map);
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		tStudentWorkService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
